package com.lovo.ssc.controller;


import com.lovo.ssc.entity.Customer;
import com.lovo.ssc.service.ICustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 客户表 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/customer")
@Api(tags = "客户控制层")
public class CustomerController {

    @Autowired
    ICustomerService customerService;

    @PostMapping("saveCustomer")
    @ApiOperation(value = "添加用户")
    public boolean saveCustomer(Customer customer){
        return customerService.save(customer);
    }

    @PutMapping("updateState/{userName}/{state}  ")
    @ApiOperation(value = "修改状态")
    public void updateState (@PathVariable("userName") String userName,
                             @PathVariable("state") String state){
        customerService.updateState(userName, state);
    }

    @PostMapping("updateGrade/{userName}/{grade}")
    @ApiOperation(value = "修改等级")
    public void updateGrade (@PathVariable("userName") String userName,
                             @PathVariable("grade") String grade){
        customerService.updateGrade(userName, grade);
    }
}
